const Mock = require('mockjs')

const Random = Mock.Random

let Result = {
	code: 200,
	msg: '操作成功',
	data: null
}

Mock.mock('/captcha', 'get', () => {

	Result.data = {
		token: Random.string(32),
		captchaImg: Random.dataImage('120x40', 'p7n5w')
	}
	return Result
})

Mock.mock('/login', 'post', () => {

	// 无法在header中传入数jwt

	// Result.code = 400
	// Result.msg = "验证码错误"

	return Result
})
Mock.mock('/sys/userInfo', 'get', () => {

	Result.data = {
		id: "1",
		title:"zzy",
		username: "赵志远",
		avatar: "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64"
	}

	return Result
})

Mock.mock('/logout', 'post', () => {

	return Result
})

// 获取用户菜单以及权限接口
Mock.mock('/sys/menu/nav', 'get', () => {

	let nav = [
		{
			name: 'SysManga',
			title: '系统管理',
			icon: 'el-icon-s-operation',
			component: '',
			path: '',
			children: [
				{
					name: 'SysUser',
					title: '用户管理',
					icon: 'el-icon-s-custom',
					path: '/sys/users',
					component: 'sys/User',
					children: []
				},
				{
					name: 'SysRole',
					title: '角色管理',
					icon: 'el-icon-rank',
					path: '/sys/roles',
					component: 'sys/Role',
					children: []
				},


			],

		},
		{
			name: 'ShopManag',
			title: '商品管理',
			icon: 'el-icon-menu',
			path: '',
			component: '',
			children: []

		},

		{
			name: 'Help',
			title: '互助信息管理',
			icon: 'el-icon-s-order',
			path: '/sys/dicts',
			component: '',
			children: [
				{
					name: 'SentMessage',
					title: '发布管理',
					icon: 'el-icon-s-tools',
		path: '/sys/sendmessages',
					component: 'sys/SendMessage',
					children: []

				},
			]
		},
		{
			name: 'LifeHelp',
			title: '生活互助审核',
			icon: 'el-icon-s-order',
			path: '',
			component: '',
			children: [

				{
					name: 'HelpCheck',
					title: '互助信息审核',
					icon: 'el-icon-s-tools',
					path: '/sys/helpchecks',
					component: 'sys/HelpCheck',
					children: []

				},
			]
		}


	]

	let authoritys = ['sys:user:list', "sys:user:save", "sys:user:delete"]

	Result.data = {
		nav: nav,
		authoritys: authoritys
	}

	return Result
})

//给角色用户分配权限

Mock.mock('/sys/menu/list', 'get', () => {
	let menus = [
		{



					"id": 2,
					"created": "2021-01-15T19:03:45",
					"updated": "2021-01-15T19:03:48",
					"statu": 1,
					"parentId": 1,
					"name": "用户管理",
					"path": "/sys/users",
					"perms": "sys:user:list",
					"component": "sys/User",
					"type": 1,
					"icon": "el-icon-s-custom",
					"ordernum": 1,
					"children": [
						{
							"id": 9,
							"created": "2021-01-17T21:48:32",
							"updated": null,
							"statu": 1,
							"parentId": 2,
							"name": "添加用户",
							"path": null,
							"perms": "sys:user:save",
							"component": null,
							"type": 2,
							"icon": null,
							"ordernum": 1,
							"children": []
						},
						{
							"id": 10,
							"created": "2021-01-17T21:49:03",
							"updated": "2021-01-17T21:53:04",
							"statu": 1,
							"parentId": 2,
							"name": "修改用户",
							"path": null,
							"perms": "sys:user:update",
							"component": null,
							"type": 2,
							"icon": null,
							"ordernum": 2,
							"children": []
						},
						{
							"id": 11,
							"created": "2021-01-17T21:49:21",
							"updated": null,
							"statu": 1,
							"parentId": 2,
							"name": "删除用户",
							"path": null,
							"perms": "sys:user:delete",
							"component": null,
							"type": 2,
							"icon": null,
							"ordernum": 3,
							"children": []
						},
						{
							"id": 12,
							"created": "2021-01-17T21:49:58",
							"updated": null,
							"statu": 1,
							"parentId": 2,
							"name": "分配角色",
							"path": null,
							"perms": "sys:user:role",
							"component": null,
							"type": 2,
							"icon": null,
							"ordernum": 4,
							"children": []
						},
						{
							"id": 13,
							"created": "2021-01-17T21:50:36",
							"updated": null,
							"statu": 1,
							"parentId": 2,
							"name": "重置密码",
							"path": null,
							"perms": "sys:user:repass",
							"component": null,
							"type": 2,
							"icon": null,
							"ordernum": 5,
							"children": []
						}
					]



		},

	]

	Result.data = menus

	return Result
})

// Mock.mock(RegExp('/sys/menu/info/*'), 'get', () => {
//
// 	Result.data = {
// 		"id": 3,
// 		"statu": 1,
// 		"parentId": 1,
// 		"name": "角色管理",
// 		"path": "/sys/roles",
// 		"perms": "sys:role:list",
// 		"component": "sys/Role",
// 		"type": 1,
// 		"icon": "el-icon-rank",
// 		"orderNum": 2,
// 		"children": []
// 	}
//
// 	return Result
// })
//
//
// Mock.mock(RegExp('/sys/menu/*'), 'post', () => {
//
// 	return Result
// })

//////////////// 角色管理 ////////////////

Mock.mock(RegExp('/sys/role/list*'), 'get', () => {

	Result.data = {
		"records": [
			{
				"id": 3,
				"created": "2021-07-30 8:20:22",
				"updated": "2021-07-30 8:55:57",
				"statu": 1,
				"name": "普通用户",
				"username": "zzy",
				"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
				"code": "normal",
				"remark": "只有基本功能",
				"menuIds": []
			},
			{
				"id": 6,
				"created": "2021-07-30 8:20:22",
				"updated": "2021-07-30 8:55:57",
				"statu": 1,
				"username": "赵志远",
				"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
				"name": "后台管理员",
				"code": "admin",
				"remark": "系统默认最高权限",
				"menuIds": []
			}
		],
		"total": 2,
		"size": 10,
		"current": 1,
		"orders": [],
		"optimizeCountSql": true,
		"hitCount": false,
		"countId": null,
		"maxLimit": null,
		"searchCount": true,
		"pages": 1
	}

	return Result

})

Mock.mock(RegExp('/sys/role/info/*'), 'get', () => {

	Result.data = {
		"id": 6,
		"created": "2021-07-30 8:20:22",
		"updated": "2021-07-30 8:55:57",
		"statu": 1,
		"name": "",
		"code": "",
		"remark": "",
		"menuIds": [3]
	}

	return Result
})

Mock.mock(RegExp('/sys/role/*'), 'post', () => {

	return Result
})

//////////////// 用户管理 ////////////////

Mock.mock(RegExp('/sys/user/list*'), 'get', () => {
	Result.data = {
		"records": [
			{
				"id": 1,
				"created": "2021-07-30 8:20:22",
				"updated": "2021-07-30 8:55:57",
				"statu": 1,
				"username": "赵志远",
				"password": "123456",
				"sex":"男",
				"phone":"19811730607",
				"school":"山东理工大学",
				"major":"软件工程",
				"sign_time":"2019-09-01",
				 "avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
				"email": "1850531227@qq.com",

				"roles": [
					{
						"id": 6,
						"created": "2021-07-30 8:20:22",
						"updated": "2021-07-30 8:55:57",
						"statu": 1,
						"name": "后台管理员",
						"code": "admin",
						"remark": "系统默认最高权限，不可以编辑和任意修改",
						"menuIds": []
					},

				]
			},
			{
				"id": 2,
				"created": "2021-07-30 8:20:22",
				"updated": "2021-07-30 8:55:57",
				"statu": 1,
				"username": "zzy",
				"password": "654321",
				"sex":"男",
				"school":"山东理工大学",
				"phone":"19811730607",
				"major":"软件工程",
				"sign_time":"2019-09-01",

				 "avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
				"email": "2869241481@qq.com",
				"city": null,
				"lastLogin": null,
				"roles": [
					{
						"id": 3,
						"created": "2021-07-30 8:20:22",
						"updated": "2021-07-30 8:55:57",
						"statu": 1,
						"name": "普通用户",
						"code": "normal",
						"remark": "只有基本查看功能",
						"menuIds": []
					}
				]
			}
		],
		"total": 2,
		"size": 10,
		"current": 1,
		"orders": [],
		"optimizeCountSql": true,
		"hitCount": false,
		"countId": null,
		"maxLimit": null,
		"searchCount": true,
		"pages": 1
	}

	return Result
})


Mock.mock(RegExp('/sys/user/*'), 'post', () => {
	return Result
})

Mock.mock(RegExp('/sys/user/info/*'), 'get', () => {

	Result.data = {
		"id": 2,
		"created": "2021-07-30 8:20:22",
		"updated": "2021-07-30 8:55:57",
		"statu": 1,
		"username": "",
		"password": "",
		"avatar": "",
		"email": "",
		"city": null,
		"lastLogin": null,
		"roles": []
	}
	return Result

})
// //////////////// 发布管理 ////////////////
// Mock.mock(RegExp('/sys/sendmessage/list*'), 'get', () => {
// 	Result.data = {
// 		"records": [
// 			{
// 				"id": 1,
// 				"created": "2021-07-30 8:20:22",
// 				"updated": "2021-07-30 8:55:57",
// 				"statu": 1,
// 				"helpname":"学习互助",
// 				"require":"希望互助对象为本校女生，人数不限",
// 				"username": "冯晓晓",
// 				"password": "123456",
// 				"sex":"女",
// 				"phone":"19811730589",
// 				"school":"山东理工大学",
// 				// "major":"软件工程",
// 				"sign_time":"2019-09-01",
// 				//"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
// 				"email": "2788578863@qq.com",
//
// 				"roles": [
// 					{
// 						"id": 6,
// 						"created": "2021-08-3 8:20:22",
// 						"updated": "2021-08-3 8:55:57",
// 						"statu": 1,
// 						"name": "后台管理员",
// 						"code": "admin",
// 						"remark": "系统默认最高权限，不可以编辑和任意修改",
// 						"menuIds": []
// 					},
//
// 				]
// 			},
// 			{
// 				"id": 2,
// 				"created": "2021-07-30 8:20:22",
// 				"updated": "2021-07-30 8:55:57",
// 				"statu": 1,
// 				"helpname":"生活互助",
// 				"require":"无",
// 				"username": "赵志远",
// 				"password": "654321",
// 				"sex":"男",
// 				"school":"山东理工大学",
// 				"phone":"19811730607",
//
// 				"sign_time":"2019-09-01",
//
// 				//"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
// 				"email": "2869241481@qq.com",
// 				"city": null,
// 				"lastLogin": null,
// 				"roles": [
// 					{
// 						"id": 3,
// 						"created": "2021-07-30 8:20:22",
// 						"updated": "2021-07-30 8:55:57",
// 						"statu": 1,
// 						"name": "普通用户",
// 						"code": "normal",
// 						"remark": "只有基本查看功能",
// 						"menuIds": []
// 					}
// 				]
// 			},
// 			{
// 				"id": 2,
// 				"created": "2021-07-30 8:20:22",
// 				"updated": "2021-07-30 8:55:57",
// 				"statu": 1,
// 				"helpname":"心理互助",
// 				"require":"恋爱方面",
// 				"username": "lucky",
// 				"password": "654321",
// 				"sex":"女",
// 				"school":"山东理工大学",
// 				"phone":"19811730607",
//
// 				"sign_time":"2019-09-01",
//
// 				//"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
// 				"email": "2869241481@qq.com",
// 				"city": null,
// 				"lastLogin": null,
// 				"roles": [
// 					{
// 						"id": 3,
// 						"created": "2021-07-30 8:20:22",
// 						"updated": "2021-07-30 8:55:57",
// 						"statu": 1,
// 						"name": "普通用户",
// 						"code": "normal",
// 						"remark": "只有基本查看功能",
// 						"menuIds": []
// 					}
// 				]
// 			},
// 			{
// 				"id": 2,
// 				"created": "2021-07-30 8:20:22",
// 				"updated": "2021-07-30 8:55:57",
// 				"statu": 1,
// 				"helpname":"勤工俭学互助",
// 				"require":"家教、代课方向",
// 				"username": "miss",
// 				"password": "654321",
// 				"sex":"男",
// 				"school":"山东理工大学",
// 				"phone":"19811730555",
//
// 				"sign_time":"2020-09-01",
//
// 				//"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
// 				"email": "2869241481@qq.com",
// 				"city": null,
// 				"lastLogin": null,
// 				"roles": [
// 					{
// 						"id": 3,
// 						"created": "2021-07-30 8:20:22",
// 						"updated": "2021-07-30 8:55:57",
// 						"statu": 1,
// 						"name": "普通用户",
// 						"code": "normal",
// 						"remark": "只有基本查看功能",
// 						"menuIds": []
// 					}
// 				]
// 			},
// 			{
// 				"id": 2,
// 				"created": "2021-07-30 8:20:22",
// 				"updated": "2021-07-30 8:55:57",
// 				"statu": 1,
// 				"helpname":"信息共享互助",
// 				"require":"需要高数期末复习资料",
// 				"username": "goods",
// 				"password": "654321",
// 				"sex":"女",
// 				"school":"山东理工大学",
// 				"phone":"19811730607",
//
// 				"sign_time":"2019-09-01",
//
// 				//"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
// 				"email": "2869241481@qq.com",
// 				"city": null,
// 				"lastLogin": null,
// 				"roles": [
// 					{
// 						"id": 3,
// 						"created": "2021-07-30 8:20:22",
// 						"updated": "2021-07-30 8:55:57",
// 						"statu": 1,
// 						"name": "普通用户",
// 						"code": "normal",
// 						"remark": "只有基本查看功能",
// 						"menuIds": []
// 					}
// 				]
// 			}
//
// 		],
// 		"total": 2,
// 		"size": 10,
// 		"current": 1,
// 		"orders": [],
// 		"optimizeCountSql": true,
// 		"hitCount": false,
// 		"countId": null,
// 		"maxLimit": null,
// 		"searchCount": true,
// 		"pages": 1
// 	}
//
// 	return Result
// })
//
//
// Mock.mock(RegExp('/sys/user/*'), 'post', () => {
// 	return Result
// })
//
// Mock.mock(RegExp('/sys/user/info/*'), 'get', () => {
//
// 	Result.data = {
// 		"id": 2,
// 		"created": "2021-07-30 8:20:22",
// 		"updated": "2021-07-30 8:55:57",
// 		"statu": 1,
// 		"username": "",
// 		"password": "",
// 		"avatar": "",
// 		"email": "",
// 		"city": null,
// 		"lastLogin": null,
// 		"roles": []
// 	}
// 	return Result
// })
//////////////// 互助审核////////////////

Mock.mock(RegExp('/sys/helpcheck/list*'), 'get', () => {

	Result.data = {
		"records": [
			{
				"id": 3,
				"created": "2021-07-30 8:20:22",
				"updated": "2021-07-30 8:55:57",
				"status": 1,
				"menuIds": []
			},
			{
				"id": 6,
				"created": "2021-07-30 8:20:22",
				"updated": "2021-07-30 8:55:57",
				"status": 1,
				"username": "fxx",
				"avatar": "https://img-blog.csdnimg.cn/20201014180756923.png?x-oss-process=image/resize,m_fixed,h_64,w_64",
				"name": "后台管理员",
				"code": "admin",
				"remark": "系统默认最高权限",
				"menuIds": []
			}
		],
		"total": 2,
		"size": 10,
		"current": 1,
		"orders": [],
		"optimizeCountSql": true,
		"hitCount": false,
		"countId": null,
		"maxLimit": null,
		"searchCount": true,
		"pages": 1
	}

	return Result

})

Mock.mock(RegExp('/sys/helpcheck/info/*'), 'get', () => {

	Result.data = {
		"id": 6,
		"created": "2021-07-30 8:20:22",
		"updated": "2021-07-30 8:55:57",
		"status": 1,
		"name": "",
		"code": "",
		"remark": "",
		"menuIds": [3]
	}

	return Result
})

Mock.mock(RegExp('/sys/helpcheck/*'), 'post', () => {

	return Result
})
//////////////// 发布管理 ////////////////
Mock.mock(RegExp('/sys/sendmessage/list*'), 'get', () => {
	Result.data = {
		"records": [
			{
				"release_uid": 123,
				"receive_uid": "fxx",
				"desc": "学习互助",
				"is_handled": 1,
				"is_finish": 1,
				"statu": 2,
				"roles": [
					{
						"id": 6,
						"created": "2021-07-30 8:20:22",
						"updated": "2021-07-30 8:55:57",
						"is_handled": 1,
						"is_finish": 1,
						"statu": 1,
						"menuIds": []
					},

				]

			},
			{
				"release_uid": 12345,
				"receive_uid": "zzy",
				"desc": "生活互助",
				"is_handled": 1,
				"is_finish": 1,
				"statu": 1,
				"roles": [
					{
						"id": 6,
						"created": "2021-07-30 8:20:22",
						"updated": "2021-07-30 8:55:57",
						"is_handled": 1,
						"is_finish": 1,
						"statu": 1,
						"menuIds": []
					},

				]

			},
			{
				"release_uid": 1234,
				"receive_uid": "mess",
				"desc": "心理互助",
				"is_handled": 1,
				"is_finish": 1,
				"statu": 1,
				"roles": [
					{
						"id": 6,
						"created": "2021-07-30 8:20:22",
						"updated": "2021-07-30 8:55:57",
						"is_handled": 1,
						"is_finish": 0,
						"statu": 1,
						"menuIds": []
					},

				]

			},

			{
				"release_uid": 66666,
				"receive_uid": "smil",
				"desc": "信息共享互助",
				"is_handled": 1,
				"is_finish": 1,
				"statu": 0,
				"roles": [
					{
						"id": 6,
						"created": "2021-07-30 8:20:22",
						"updated": "2021-07-30 8:55:57",
						"is_handled": 1,
						"is_finish": 1,
						"statu": 0,
						"menuIds": []
					},

				]

			},

		],
		"total": 2,
		"size": 10,
		"current": 1,
		"orders": [],
		"optimizeCountSql": true,
		"hitCount": false,
		"countId": null,
		"maxLimit": null,
		"searchCount": true,
		"pages": 1
	}

	return Result
})

Mock.mock(RegExp('/sys/sendmessage/*'), 'post', () => {
	return Result
})

Mock.mock(RegExp('/sys/sendmessage/info/*'), 'get', () => {

	Result.data = {
		"id": 2,
		"created": "2021-07-30 8:20:22",
		"updated": "2021-07-30 8:55:57",
		"statu": 1,
		"is_handled": 1,
		"is_finish": 1,
		"username": "",
		"password": "",
		"avatar": "",
		"email": "",
		"city": null,
		"lastLogin": null,
		"roles": []
	}
	return Result
})
